var fs = require('fs')

try {
  fs.mkdirSync('./logs')
} catch (e) {
  if (e.code !== 'EEXIST') {
    console.error('Could not set up log directory, error was: ', e)
  }
}

var log4js = require('log4js')

log4js.configure({
  appenders: [{
    type: 'dateFile',
    filename: './logs/agent.log',
    pattern: '-yyyy-MM-dd',
    category: 'agent'
  }]
})

var logger = log4js.getLogger('agent')
logger.setLevel('INFO')

module.exports = logger
